//package com.smart.framework.config;
//
//import com.arcsoft.face.ActiveFileInfo;
//import com.arcsoft.face.EngineConfiguration;
//import com.arcsoft.face.FaceEngine;
//import com.arcsoft.face.FunctionConfiguration;
//import com.arcsoft.face.enums.DetectMode;
//import com.arcsoft.face.enums.DetectOrient;
//import com.arcsoft.face.enums.ErrorInfo;
//import com.smart.common.exception.ServiceException;
//import com.smart.common.utils.arcSoft.ArcSoftTemplate;
//import com.smart.framework.config.properties.ArcSoftProperties;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class ArcSoftConfig {
//
//    @Autowired
//    private ArcSoftProperties arcSoftProperties;
//
//
//    @Bean
//    public ArcSoftTemplate arcSoftTemplate() {
//        FaceEngine faceEngine = new FaceEngine(ClassLoader.getSystemClassLoader().getResource(arcSoftProperties.getUrl()).getPath());
//        //激活引擎
//        int errorCode = faceEngine.activeOnline(arcSoftProperties.getAppId(), arcSoftProperties.getAppKey());
//        if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
//            throw new ServiceException("引擎激活失败");
//        }
//
//
//        ActiveFileInfo activeFileInfo=new ActiveFileInfo();
//        errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
//        if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
//            throw new ServiceException("引擎激活失败");
//        }
//
//        //引擎配置
//        EngineConfiguration engineConfiguration = new EngineConfiguration();
//        engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
//        engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
//        engineConfiguration.setDetectFaceMaxNum(10);
//        engineConfiguration.setDetectFaceScaleVal(16);
//        //功能配置
//        FunctionConfiguration functionConfiguration = new FunctionConfiguration();
//        functionConfiguration.setSupportAge(true);
//        functionConfiguration.setSupportFace3dAngle(true);
//        functionConfiguration.setSupportFaceDetect(true);
//        functionConfiguration.setSupportFaceRecognition(true);
//        functionConfiguration.setSupportGender(true);
//        functionConfiguration.setSupportLiveness(true);
//        functionConfiguration.setSupportIRLiveness(true);
//        engineConfiguration.setFunctionConfiguration(functionConfiguration);
//
//
//        //初始化引擎
//        errorCode = faceEngine.init(engineConfiguration);
//
//        if (errorCode != ErrorInfo.MOK.getValue()) {
//            System.out.println("初始化引擎失败");
//        }
//        return new ArcSoftTemplate(faceEngine);
//    }
//}
